class Solution
{
public:
    double myPow(double x, int n)
    {
        if (n < 0)
        {
            double ret = Pow(x, -(long long)n);
            return 1.0 / ret;
        }
        return Pow(x, n);
    }
    double Pow(double x, long long n)
    {
        if (n == 0) return 1;
        double tmp = Pow(x, n / 2);
        return (n % 2 == 0) ? tmp * tmp : tmp * tmp * x;
    }
};